function datetime() {
    var now = new Date();
    document.getElementById("time").value = now.getFullYear() + "-"
        + (now.getMonth() + 1) + "-" + now.getDate()+" ";
    document.getElementById("time").value += " " + now.getHours() + ":"
        + now.getMinutes() + ":" + now.getSeconds();
}
window.setInterval("datetime()");